import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity('merchants')
export class merchants {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  logo_url: string;

  @Column({ default: null })
  cover_image: string;

  @Column({ default: null })
  banner: string;
 
  @Column({ default: null })
  description: string;

  @Column({ default: null })
  address: string;

  @Column({ type: 'float' })
  longitude: number;

  @Column({ type: 'float' })
  latitude: number;

  @Column({ default: null })
  phone: string;

  @Column({ default: null })
  business_hours: string;

  @Column({ default: 5.0,type: 'float' })
  rating: number;

  @Column({ default: 0,type: 'float' })
  monthly_sales: number;

  @Column({ default: 0,type: 'float' })
  average_price: number;

  @Column({ default: 0 })
  status: number;

  @Column({ default: null })
  admin_id: number;

  @Column({default: () => 'CURRENT_TIMESTAMP'})
  create_time: Date;

  @Column({default: () => 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'})
  update_time: Date;

  // 添加构造函数支持从对象初始化
  constructor(data?: Partial<merchants>) {
    if (data) {
        Object.assign(this, data);
    }
}
}
